package com.ruoyi.recipe.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.recipe.mapper.RecipeCategoryDishMapper;
import com.ruoyi.recipe.domain.RecipeCategoryDish;
import com.ruoyi.recipe.service.IRecipeCategoryDishService;
import com.ruoyi.common.core.text.Convert;

/**
 * 菜品和类别Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-03
 */
@Service
public class RecipeCategoryDishServiceImpl implements IRecipeCategoryDishService {
    @Autowired
    private RecipeCategoryDishMapper recipeCategoryDishMapper;

    @Override
    public RecipeCategoryDish selectRecipeCategoryDishByKeys(RecipeCategoryDish recipeCategoryDish) {
        return recipeCategoryDishMapper.selectRecipeCategoryDishByKeys(recipeCategoryDish);
    }

    @Override
    public List<RecipeCategoryDish> selectRecipeCategoryDishList(RecipeCategoryDish recipeCategoryDish) {
        return recipeCategoryDishMapper.selectRecipeCategoryDishList(recipeCategoryDish);
    }

    @Override
    public List<RecipeCategoryDish> selectRecipeCategoryDishFullList(RecipeCategoryDish recipeCategoryDish) {
        return recipeCategoryDishMapper.selectRecipeCategoryDishFullList(recipeCategoryDish);
    }

    @Override
    public List<RecipeCategoryDish> selectRecipeCategoryDishByCategoryId(Long categoryId) {
        return recipeCategoryDishMapper.selectRecipeCategoryDishByCategoryId(categoryId);
    }

    @Override
    public List<RecipeCategoryDish> selectRecipeCategoryDishByDishId(Long dishId) {
        return recipeCategoryDishMapper.selectRecipeCategoryDishByDishId(dishId);
    }

    @Override
    public int insertRecipeCategoryDish(RecipeCategoryDish recipeCategoryDish) {
        return recipeCategoryDishMapper.insertRecipeCategoryDish(recipeCategoryDish);
    }

    @Override
    public int batchInsertRecipeCategoryDish(List<RecipeCategoryDish> list) {
        return recipeCategoryDishMapper.batchInsertRecipeCategoryDish(list);
    }

    @Override
    public int batchInsertRecipeCategoryDish(Long categoryId, String dishIds) {
        Long[] dishIdList = Convert.toLongArray(dishIds);
        List<RecipeCategoryDish> list = new ArrayList<>();
        for (Long dishId : dishIdList) {
            RecipeCategoryDish en = new RecipeCategoryDish();
            en.setCategoryId(categoryId);
            en.setDishId(dishId);
            list.add(en);
        }
        return this.batchInsertRecipeCategoryDish(list);
    }

    @Override
    public int deleteRecipeCategoryDishByCategoryId(Long categoryId) {
        return recipeCategoryDishMapper.deleteRecipeCategoryDishByCategoryId(categoryId);
    }

    @Override
    public int deleteRecipeCategoryDishByCategoryIds(String[] categoryIds) {
        return recipeCategoryDishMapper.deleteRecipeCategoryDishByCategoryIds(categoryIds);
    }

    @Override
    public int deleteRecipeCategoryDishByDishId(Long dishId) {
        return recipeCategoryDishMapper.deleteRecipeCategoryDishByDishId(dishId);
    }

    @Override
    public int deleteRecipeCategoryDishByDishIds(String[] dishIds) {
        return recipeCategoryDishMapper.deleteRecipeCategoryDishByDishIds(dishIds);
    }

    @Override
    public int deleteRecipeCategoryDish(RecipeCategoryDish recipeCategoryDish) {
        return recipeCategoryDishMapper.deleteRecipeCategoryDish(recipeCategoryDish);
    }

    @Override
    public int deleteRecipeCategoryDishByKeys(Long categoryId, Long[] dishIds) {
        return recipeCategoryDishMapper.deleteRecipeCategoryDishByKeys(categoryId, dishIds);
    }

    @Override
    public int deleteRecipeCategoryDishByKeys(Long categoryId, String dishIds) {
        Long[] dishIdList = Convert.toLongArray(dishIds);
        return this.deleteRecipeCategoryDishByKeys(categoryId, dishIdList);
    }
}
